package com.aspose.cells;

import java.util.ArrayList;

class zarc {
   static void a(zcfx var0, zbtz var1, String var2) throws Exception {
      if (var1 != null && var1.i() != null && !"".equals(var1.i())) {
         String var3 = var1.i();
         var0.b("text:p");
         if (var2 != null && !"".equals(var2)) {
            var0.a("text", "style-name", (String)null, var2);
         }

         if (var1.p() != null && var1.p().size() != 0) {
            ArrayList var4 = var1.r();
            int var5 = -1;
            String var6 = null;

            for(int var7 = 0; var7 < var4.size(); ++var7) {
               FontSetting var8 = (FontSetting)var4.get(var7);
               if (var8.getStartIndex() >= var3.length()) {
                  break;
               }

               if (var8.getStartIndex() - var5 != 1) {
                  var6 = var3.substring(var5 + 1, var5 + 1 + (var8.getStartIndex() - var5 - 1));
                  a(var0, var6, var1.n(), var2);
               }

               if (var8.getStartIndex() + var8.getLength() >= var3.length()) {
                  var6 = var3.substring(var8.getStartIndex());
               } else {
                  var6 = var3.substring(var8.getStartIndex(), var8.getStartIndex() + var8.getLength());
               }

               a(var0, var6, var8.c() == null ? 0 : var8.getFont().j(), var2);
               var5 = var8.getStartIndex() + var8.getLength() - 1;
               if (var5 >= var3.length()) {
                  break;
               }
            }
         } else {
            a(var0, var3, var1.n(), var2);
         }

         var0.b();
      }
   }

   private static void a(zcfx var0, String var1, int var2, String var3) throws Exception {
      String[] var4 = com.aspose.cells.b.a.zv.d(var1, '\n');

      for(int var5 = 0; var5 < var4.length; ++var5) {
         if (var4[var5] != null && !"".equals(var4[var5])) {
            var0.b("text:span");
            var0.a("text", "style-name", (String)null, "T" + zaqh.a(var2));
            var0.a(var4[var5]);
            var0.b();
         }

         if (var5 != var4.length - 1) {
            var0.b();
            var0.b("text:p");
            var0.a("text", "style-name", (String)null, var3);
         }
      }

   }
}
